# RUN: tf-mlir-translate -graphdef-to-mlir -tf-enable-shape-inference-on-import=false %s -o - | FileCheck %s

# CHECK-LABEL:       func @main() {

# Verify that the NameAttrList is properly turned into reference to functions on import
# CHECK:    tf.Case
# CHECK-SAME: branches = [@[[FOO:[a-z0-9]+]], @[[BAR:[a-z0-9]+]]]
# CHECK-DAG:  func private @[[FOO]]()
# CHECK-DAG:  func private @[[BAR]]()

node {
  name: "predicate"
  op: "Const"
  attr {
    key: "dtype"
    value {
      type: DT_INT32
    }
  }
  attr {
    key: "value"
    value {
      tensor {
        dtype: DT_INT32
        tensor_shape {
        }
        int_val: 0
      }
    }
  }
  experimental_debug_info {
  }
}
node {
  name: "Case"
  op: "Case"
  input: "predicate"
  attr {
    key: "Tin"
    value {
      list {
      }
    }
  }
  attr {
    key: "Tout"
    value {
      list {
        type: DT_FLOAT
      }
    }
  }
  attr {
    key: "branches"
    value {
      list {
        func {
          name: "foo"
        }
        func {
          name: "bar"
        }
      }
    }
  }
  attr {
    key: "output_shapes"
    value {
      list {
      }
    }
  }
  experimental_debug_info {
  }
}
library {
  function {
    signature {
      name: "bar"
      output_arg {
        name: "bar"
        type: DT_FLOAT
      }
    }
    node_def {
      name: "const_2"
      op: "Const"
      attr {
        key: "dtype"
        value {
          type: DT_FLOAT
        }
      }
      attr {
        key: "value"
        value {
          tensor {
            dtype: DT_FLOAT
            tensor_shape {
              dim {
                size: 10
              }
            }
            float_val: 2
          }
        }
      }
      experimental_debug_info {
        original_node_names: "const_2"
      }
    }
    ret {
      key: "bar"
      value: "const_2:output:0"
    }
  }
  function {
    signature {
      name: "foo"
      output_arg {
        name: "foo"
        type: DT_FLOAT
      }
    }
    node_def {
      name: "const_1"
      op: "Const"
      attr {
        key: "dtype"
        value {
          type: DT_FLOAT
        }
      }
      attr {
        key: "value"
        value {
          tensor {
            dtype: DT_FLOAT
            tensor_shape {
              dim {
                size: 10
              }
            }
            float_val: 1
          }
        }
      }
      experimental_debug_info {
        original_node_names: "const_1"
      }
    }
    ret {
      key: "foo"
      value: "const_1:output:0"
    }
  }
}
versions {
  producer: 29
  min_consumer: 12
}

